package test.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import test.springmvc.dao.UserMapper;
import test.springmvc.pojo.User;
import wechart.Util;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


@Controller
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserMapper userMapper;

    @RequestMapping(value = "/show",method = RequestMethod.GET)
    public   @ResponseBody
    User helloMvc(HttpServletRequest request, Model model){
        int id = Integer.parseInt(request.getParameter("id"));
        User mes=this.userMapper.selectByPrimaryKey(id);
        Util ttt=new Util();
        mes.setUsername(ttt.getName());
        model.addAttribute("user",mes);
        return mes;
    }
}
